package 算法.手动输入数据练习;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author coderFu
 * @create 2022/3/16
 * 手动输入并排序
 */
public class CoderStringSort {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()){
            int p = sc.nextInt();
            String[] array = new String[p];
            for(int i=0; i<p; i++){
                String a = sc.next();
                array[i] = a;
            }
            System.out.println(Arrays.toString(array));
            System.out.println(sort(array));

        }
    }
    public static String sort(String[] array){
        StringBuilder s = new StringBuilder();
        for(int i=0; i<array.length; i++){
            for(int j=i+1; j<array.length; j++){
                String b = array[i];
                char temp = b.charAt(0);
                String c = array[j];
                char d = c.charAt(0);
                if(temp > d){
                    array[i] = array[j];
                    array[j] = b;
                }
            }
        }
        for(int i=0; i<array.length; i++){
            if(i == array.length-1){
                s.append(array[i]);
            }else{
                s.append(array[i]).append(" ");
            }
        }
        return s.toString();
     }
}

